<?php
class TrainingsController extends AppController {
    public function beforeFilter() {
        $this->Auth->allow('index');
    }
    public function isAuthorized($user) {
        $this->loadModel('User');
        $this->User->id = $user['id'];
        $this->User->unbindModel(array('hasMany' => array('Test')));
        $role = $this->User->read('role');
        if($role['User']['role'] == 'none') {
            if(in_array($this->action, array('index'))) {
                return true;
            }
        }
        if($role['User']['role'] == 'admin') {
            if(in_array($this->action, array('index'))) {
                return true;
            }
        }
    }
    
    public function index() {
        $this->set('title_for_layout', 'Thư viện đề thi thử :: ChomoTech');
    }
}
?>